import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';
import { HttpService } from '../../service/http.service';
import { PTRComponent, ToptipsComponent } from 'ngx-weui';

@Component({
  selector: 'app-hospindex',
  templateUrl: './hospindex.component.html',
  styleUrls: ['./hospindex.component.css']
})

export class HospindexComponent implements OnInit {

  //hospindexurl = 'hisinfo!getHospitalInfoByCode';
  hospindexurl = 'assets/mock/hosp.json';
  hospid: any;
  hospindex: any;
  type = 'loading';
  first = false;
  err = false;
  kk = false;

  @ViewChild('toptips') toptips: ToptipsComponent;
  constructor(public routerdata: ActivatedRoute, private router: Router,
    private listdata: HttpService) {
  }

  ngOnInit() {
    this.routerdata.params.subscribe((params: Params) => this.hospid = params['id']);//从路由取值
    this.getHospData();
  }
  //读取医院详细数据
  getHospData() {
    //this.listdata.httpGet(this.hospindexurl,"{'hcode':'YCRMYY'}").subscribe(res => {
    this.listdata.httpGet2(this.hospindexurl, "{'hcode':'YCRMYY'}").subscribe(res => {
      this.hospindex = res;
      if (this.hospindex == 'err') {
        this.first = true;
        //this.err = true;
        //this.hospindex = null;
      } else {
        this.kk = true;
        this.first = true;
      }
      console.log('first', this.first);
      console.log('接口名:' + this.hospindexurl, this.hospindex);
    });
  }


}
